package com.statics;

public class Test {
    public static void main(String[] args){


        int[] a = {4,1,66,8,45,78,26,94,62,77,12,41};
        //quicksort
        quicksort(a,0,a.length-1);
        for(int i:a){
            System.out.print(i+" ");
        }





    }

    private static void quicksort(int[] a, int left, int right) {


        int l = left;
        int r=right;


        if(l>=r){
            return;
        }
        int x=a[l];
        while(l<r){

            while(l<r&&a[r]>=x){
                r--;
            }

            if(l<r){
                a[l]=a[r];
                l++;
            }

            while(l<r&&a[l]<=x){
                l++;
            }

            if(l<r){
                a[r]=a[l];
                r--;
            }

        }

        a[l]=x;
        quicksort(a,left,l-1);
        quicksort(a,l+1,right);

    }


}
